<?php
namespace App\Http\Controllers\PcWeb;

use App\Http\Controllers\ApiController;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Auth;
use App\Models\ShopJoinin;

class IndexController extends ApiController
{
    //首页
    public function index() {
        return view('pc.index');
    }
    //商家入驻
    public function shopJoin() {
        return view('pc.shop_join');
    }
    //城市代理
    public function cityAgent() {
        return view('pc.city_agent');
    }
    //关于我们
    public function aboutUs() {
        return view('pc.about_us');
    }
    //招贤纳士
    public function recruit() {
        return view('pc.recruit');
    }
    //提交商家入驻信息
    public function submitShopJoin() {
        $name = $this->request->get('name');
        $sex = $this->request->get('sex');
        $mobile = $this->request->get('mobile');
        if($this->request->has('city')) {
            $city = $this->request->get('city');
        } else {
            $city = 0;
        }
        $count = ShopJoinin::where('phone', $mobile)->get()->count();
        if($count > 0) {
            return $this->responseError('您已提交过');
        }
        if(!$name||!$sex||!$mobile) {
            return $this->responseError('信息不完整');
        }
        $ShopJoinIn = ShopJoinin::create([
            'name' => $name,
            'sex' => $sex,
            'phone' => $mobile,
            'businesstype' => '',
            'city' => $city
        ]);
        $ShopJoinIn->save();
        return $this->responseSuccessMessage('提交成功');
    }
}